package com.fuze.questionnaire.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author sepc_
 * @date 10/15/2021 10:26
 * Swagger3 配置
 */
@EnableKnife4j
@Configuration
public class SwaggerConfig {

    /**
     * Swagger Docket 的bean实例
     *
     * @return Docket 的Bean实例
     */
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(getApiInfo())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo getApiInfo() {
        return new ApiInfoBuilder()
                .title("健康自测问卷小程序后端API文档")
                .description("")
                .contact(new Contact("服泽能源科技有限公司-研发部",
                        "https:ly-az.com",
                        "sepc_chenwei@126.com"))
                .version("1.0")
                .build();
    }
}
